<HTML><HEAD><TITLE>writeq(+Stream, ?Term)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Term I/O</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>writeq(+Stream, ?Term)</H1>
The term Term is written on the output stream Stream in a form that can be
read in.


<DL>
<DT><EM>Stream</EM></DT>
<DD>Integer (stream number) or Atom (reserved or user-defined                symbolic stream name).
</DD>
<DT><EM>Term</EM></DT>
<DD>Prolog term.
</DD>
</DL>
<H2>Description</H2>

   Used to write the term Term on the output stream Stream according
   to the current operator declarations.  Atoms and strings are
   quoted, operator expressions parenthesised (whenever necessary) and
   the (stream-specific or global) print_depth flag is not taken into
   account.  The output of writeq/2 can be read back, provided that
   the same operator declarations are in effect at write and read
   time.  writeq(S, Term) is equivalent to printf(S, "%QDvw", Term).

<P>
   Note that as usual, the output is buffered, so it may need to be flushed
   either by closing the stream, by writing again or by using flush/1.

<P>
   Note also that although it is possible to print suspensions and external
   handles, these are printed in their printed representation as Prolog
   terms with functors such as 'BAG' (for bag objects). They will be read
   back in as such Prolog terms, rather than as their original type. 

<P>

<H3>Modes and Determinism</H3><UL>
<LI>writeq(+, ?) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Stream is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Stream is not an atom or an integer.
<DT><EM>(192) illegal stream mode </EM>
<DD>Stream is not an output stream.
<DT><EM>(193) illegal stream specification </EM>
<DD>Stream is an illegal stream specification.
</DL>
<H2>Examples</H2>
<PRE>
   Success:
      [eclipse]: writeq(output, "string"),nl(output),
      &gt; writeq(output, head:-body).
      "string"
      head :- body
      yes.

      [eclipse]: writeq(*(^(1,2),+(3,4))).
      1 ^ 2 * (3 + 4)
      yes.
Error:
      writeq(S, a(b,c)).        (Error 4).
      writeq("string", a(b,c)). (Error 5).
      writeq(9, X + 2).         (Error 192).
      writeq(atom, X + 2).      (Error 193).


</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/ioterm/write-1.html">write / 1</A>, <A HREF="../../kernel/ioterm/write-2.html">write / 2</A>, <A HREF="../../kernel/ioterm/writeq-1.html">writeq / 1</A>
</BODY></HTML>
